package com.booking.springrestful.controller;

import com.booking.springrestful.domain.Feedback;
import com.booking.springrestful.domain.Users;
import com.booking.springrestful.domain.dto.FeedbackDto;
import com.booking.springrestful.domain.vo.CounselorsVo;
import com.booking.springrestful.domain.vo.FeedbackVo;
import com.booking.springrestful.resp.PageResult;
import com.booking.springrestful.resp.ResponseResult;
import com.booking.springrestful.service.FeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/feedback")
@Slf4j
public class feedbackController {

    @Resource
    private FeedbackService feedbackService;

    //查询所有咨询师账号
    @GetMapping("/getAllCounselor")
    private ResponseResult<List<CounselorsVo>> getUsername(){
        List<CounselorsVo> list= feedbackService.getAllCounselor();
        return ResponseResult.success(list);
    }


    //提交反馈表
    @PostMapping("/submitFeedback")
    private ResponseResult<String> submitFeedback(@RequestBody Feedback feedback){
        feedbackService.submitFeedback(feedback);
        return ResponseResult.success("提交成功");
    }

    //根据咨询师id查询反馈记录
    @PostMapping("/getFeedback")
    private ResponseResult<PageResult<FeedbackVo>> getFeedback(@RequestBody FeedbackDto feedbackDto){
        PageResult<FeedbackVo> page= feedbackService.getFeedback(feedbackDto);
        return ResponseResult.success(page);
    }


    //判断是否已经反馈过
    @GetMapping("/isFeed")
    private ResponseResult<Boolean> isFeed(@RequestParam("id") Integer id){
        Boolean flag=feedbackService.isFeed(id);
        return ResponseResult.success(flag);
    }

    //查询当前预约单的反馈记录
    @GetMapping("/getByAppId")
    private ResponseResult<Feedback> getByAppId(@RequestParam("id") Integer id){
        Feedback feedback= feedbackService.getByAppId(id);
        return ResponseResult.success(feedback);
    }
}
